﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;

namespace Cos.Core.Service
{
    public static class ServiceLocator
    {
        static ServiceLocator()
        {
        }

        public static IUnityContainer Container { get; set; }

        public static T Get<T>()
        {
            return Container.Resolve<T>();
        }

        public static IEnumerable<Type> FindTypes<TParent>()
        {
            return Container.Registrations.Where(r => typeof(TParent).IsAssignableFrom(r.RegisteredType)).Select(r => r.RegisteredType);
        }
    }
}
